clear; close all; clc; 

load ../data/music_dataset.mat
addpath 'CV/' 'DT/' 'Lyrics_Kernel/' 'SVM/libsvm/'

[Xt_lyrics] = make_lyrics_sparse(train, vocab);
[Xq_lyrics] = make_lyrics_sparse(quiz, vocab);

Yt = zeros(numel(train), 1);
for i=1:numel(train)
    Yt(i) = genre_class(train(i).genre);
end

Xt_audio = make_audio(train);
Xq_audio = make_audio(quiz);

%% Run stemmer on the example matrices 

Xt_lyrics = stemmer(Xt_lyrics,vocab);
fprintf('Stemming Complete \n');

%%
clear Xq_audio Xq_lyrics Yt feature_desc quiz train vocab;
matches = zeros(size(Xt_lyrics,1),1);

for i=1:size(Xt_lyrics,1)
   if(mod(i,1000)==0)
       disp(['Row #: ' num2str(i)]);
   end
    
   if(matches(i)~= 0)
       continue;
   end
      
   a = bsxfun(@eq, Xt_lyrics(i,:),Xt_lyrics); 
   matches = i*(sum(a,2) == size(Xt_lyrics,2)) + matches;
   clear a;
end